package com.itheima.list;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/*
List 的遍历方式
 */
public class Demo02 {

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("坤坤");
        list.add("签签");
        list.add("滔滔");
        list.add("小鹿");


        //迭代器
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()){
            String s = iterator.next();
            System.out.println(s);
        }
        System.out.println("===================");
        //增强for

        for (String s : list) {
            System.out.println(s);
        }
        System.out.println("===================");
        //foreach
        list.forEach(s -> System.out.println(s));
        System.out.println("===================");
        //fori
        for (int i = 0; i < list.size(); i++) {

            String s = list.get(i);
            System.out.println(s);
        }

    }
}
